import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/components/Login'
import Home from '@/components/Home'
import WelCome from '@/components/WelCome'
import NoticeManager from "@/components/notice/NoticeManager";
import Admin from '@/components/Admin'

import UserManager from '@/components/user/UserManager'
import AddUser from '@/components/user/AddUser'
import UpdateUser from '@/components/user/UpdateUser'
import RoleManager from '@/components/role/RoleManager'
import EditRoleMenu from '@/components/role/EditRoleMenu'
import UserRoleManager from '@/components/role/UserRoleManager'
import PersonalManager from '@/components/own/PersonalManager'
import OrderManager from '@/components/order/OrderManager';
import CustomerOrderManager from '@/components/order/CustomerOrderManager';
import KnowledgeManager from "@/components/exercise/KnowledgeManager";
import AddExercise from "@/components/exercise/AddExercise";
import UpdatExercise from "@/components/exercise/UpdatExercise";
import InvestManager from "@/components/invest/InvestManager";

import * as echarts from 'echarts'   //导入Echarts

Vue.use(VueRouter)
Vue.prototype.$echarts=echarts;
const routes = [
  {
    path: '/',
    name: 'Admin',
    component: Admin
  },
  {
    path: '/Login',
    name: 'Login',
    component: Login
  },
  {
    path: '/Home',
    name: 'Home',
    component: Home,
    redirect:'/WelCome',
    children:[
      {path:'/WelCome' , name:'WelCome' , component:WelCome},
      {path:'/UserManager' , name:'UserManager' , component:UserManager},
      {path:'/user/AddUser' , name:'AddUser' , component:AddUser},
      {path:'/user/UpdateUser' , name:'UpdateUser' , component:UpdateUser},
      {path:'/RoleManager' , name:'RoleManager' , component:RoleManager},
      {path:'/role/EditRoleMenu' , name:'EditRoleMenu' , component:EditRoleMenu},
      {path:'/UserRoleManager' , name:'UserRoleManager' , component:UserRoleManager},
      {path:'/PersonalManager' , name:'PersonalManager' , component:PersonalManager},
      {path: '/NoticeManager' , name: 'NoticeManager' , component: NoticeManager},
      {path:'/OrderManager' , name: 'OrderManager' , component: OrderManager},
      {path:'/CustomerOrderManager' , name: 'CustomerOrderManager' , component: CustomerOrderManager},
      {path: '/KnowledgeManager' ,name: 'KnowledgeManager' ,component: KnowledgeManager},
      {path: '/exercise/AddExercise',name: 'AddExercise',component: AddExercise},
      {path:'/exercise/UpdatExercise',name: 'UpdatExercise',component: UpdatExercise},
      {path: '/InvestManager',name: 'InvestManager',component: InvestManager},
    ]
  },
]

const router = new VueRouter({
  routes
})

// 解决点击重复路由报错
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

export default router
